package cn.source.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.source.common.annotation.Log;
import cn.source.common.core.controller.BaseController;
import cn.source.common.core.domain.AjaxResult;
import cn.source.common.enums.BusinessType;
import cn.source.system.domain.GkZytbDetail;
import cn.source.system.service.IGkZytbDetailService;
import cn.source.common.utils.poi.ExcelUtil;
import cn.source.common.core.page.TableDataInfo;

/**
 * 模拟志愿填报明细Controller
 *
 * @author sourcebyte.vip
 * @date 2024-12-02
 */
@RestController
@RequestMapping("/system/gkZytbDetail")
public class GkZytbDetailController extends BaseController
{
    @Autowired
    private IGkZytbDetailService gkZytbDetailService;

    /**
     * 查询模拟志愿填报明细列表
     */
    @PreAuthorize("@ss.hasPermi('system:gkZytbDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(GkZytbDetail gkZytbDetail)
    {
        startPage();
        List<GkZytbDetail> list = gkZytbDetailService.selectGkZytbDetailList(gkZytbDetail);
        return getDataTable(list);
    }

    /**
     * 获取模拟志愿填报明细详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(gkZytbDetailService.selectGkZytbDetailById(id));
    }

    /**
     * 新增模拟志愿填报明细
     */
    @PreAuthorize("@ss.hasPermi('system:gkZytbDetail:add')")
    @Log(title = "模拟志愿填报明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GkZytbDetail gkZytbDetail)
    {
        return toAjax(gkZytbDetailService.insertGkZytbDetail(gkZytbDetail));
    }

    /**
     * 修改模拟志愿填报明细
     */
    @PreAuthorize("@ss.hasPermi('system:gkZytbDetail:edit')")
    @Log(title = "模拟志愿填报明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GkZytbDetail gkZytbDetail)
    {
        return toAjax(gkZytbDetailService.updateGkZytbDetail(gkZytbDetail));
    }

    /**
     * 删除模拟志愿填报明细
     */
    @PreAuthorize("@ss.hasPermi('system:gkZytbDetail:remove')")
    @Log(title = "模拟志愿填报明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(gkZytbDetailService.deleteGkZytbDetailByIds(ids));
    }

    /**
     * 导出模拟志愿填报明细列表
     */
    @PreAuthorize("@ss.hasPermi('system:gkZytbDetail:export')")
    @Log(title = "模拟志愿填报明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GkZytbDetail gkZytbDetail)
    {
        List<GkZytbDetail> list = gkZytbDetailService.selectGkZytbDetailList(gkZytbDetail);
        ExcelUtil<GkZytbDetail> util = new ExcelUtil<GkZytbDetail>(GkZytbDetail.class);
        util.exportExcel(response, list, "模拟志愿填报明细数据");
    }
}
